<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">


<h:body>

<h:form id="productTagInputForm">
         <p:growl id="messages" showDetail="true"/> 
          
        <h:inputHidden id="hidden" value="#{productTagBean.newProductTag.productTagId}" />    
        <h:panelGrid columns="2" cellpadding="5">  
        
            <h:outputLabel for="ProductId" value="ProductId: *" />  
            <p:row> 
            <p:inputText value="#{productTagBean.newProductTag.productId}"   
                    id="newProductTag_productId"  label="newProductTag_productId" />
            <p:commandButton  id="chooseProductButton" value="Choose Product"   oncomplete="dlg.show()" />  
            </p:row>
              
            <h:outputLabel for="Tagtype" value="Tagtype:" />  
            <p:selectOneMenu value="#{productTagBean.newProductTag.tagType}" >  
			            <f:selectItem itemLabel="featured" itemValue="featured" />
			            <f:selectItem itemLabel="hotbuy" itemValue="hotbuy" /> 
	        </p:selectOneMenu> 
                    
            <h:outputLabel for="displayOrder" value="Display Order:" />  
            <p:inputText value="#{productTagBean.newProductTag.displayOrder}"   
                    id="newdisplayOrder" label="displayOrder" /> 
              
            <f:facet name="footer">  
                <p:commandButton id="addProductTagButton" value="Submit" update=":centerContentPanel"   
                    actionListener="#{productTagBean.onAddSubmit}"   
                    />  
            </f:facet>  
        </h:panelGrid> 
                
</h:form>

<p:dialog id="chooseProduct" header="Choose Product" widgetVar="dlg" modal="true" appendToBody="true">  
   <h:form>
        <p:dataTable var="product" selection="#{productTagBean.selectedProduct}" selectionMode="single"    rowKey="#{product.productId}" value="#{productTagBean.productList}"   id="productList"  >  
  
        <f:facet name="header">  
            Product List  
        </f:facet>  
  
        <p:column headerText="Id" style="width:125px">  
            <p:cellEditor>  
                <f:facet name="output">  
                    <h:outputText value="#{product.productId}" />  
                </f:facet>  
                <f:facet name="input">  
                    <p:inputText value="#{product.productId}" required="true"  style="width:100%"  />  
                </f:facet>  
            </p:cellEditor>  
        </p:column>  
  
        <p:column headerText="productName" style="width:225px">  
            <p:cellEditor>  
                <f:facet name="output">  
                    <h:outputText value="#{product.productName}" />  
                </f:facet>  
                <f:facet name="input">  
                    <p:inputText value="#{product.productName}" style="width:100%" label="Year"/>  
                </f:facet>  
            </p:cellEditor>  
        </p:column>
        
         <p:column headerText="categoryId" style="width:125px">  
            <p:cellEditor>  
                <f:facet name="output">  
                    <h:outputText value="#{product.categoryId}" />  
                </f:facet>  
                <f:facet name="input">  
                    <p:inputText value="#{product.categoryId}" style="width:100%" label="Year"/>  
                </f:facet>  
            </p:cellEditor>  
        </p:column>
        
         <p:column headerText="order" style="width:125px">  
            <p:cellEditor>  
                <f:facet name="output">  
                    <h:outputText value="#{product.displayOrder}" />  
                </f:facet>  
                <f:facet name="input">  
                    <p:inputText value="#{product.displayOrder}" style="width:100%" label="Year"/>  
                </f:facet>  
            </p:cellEditor>  
        </p:column>
  
        <f:facet name="footer">  
            <p:commandButton  id="choose" value="Choose" icon="ui-icon-add"  action="#{productTagBean.chooseProduct}"   onclick="handleLoginRequest(xhr, status, args)" update=":centerContentPanel"/> 
        </f:facet>
        
    </p:dataTable>  
  </h:form>        
   
</p:dialog> 



<script type="text/javascript">  
    function handleLoginRequest(xhr, status, args) {  
//         if(args.validationFailed || !args.loggedIn) {  
//             jQuery('#addDialog').effect("shake", { times:3 }, 100);  
//         } else {  
            dlg.hide();  
//         }  
    }  
</script>


</h:body>

</html>